package org.pearl.springbootsecurity.demo.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.pearl.springbootsecurity.demo.MP.data.DataScope;
import org.pearl.springbootsecurity.demo.MP.data.DataScopeType;
import org.pearl.springbootsecurity.demo.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.pearl.springbootsecurity.demo.pojo.UserInfoDO;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author td
 * @since 2021-07-02
 */
@DataScope(type = DataScopeType.OWN_AND_CHILD_DEPT)
public interface UserMapper extends BaseMapper<User> {



    @Select("SELECT\n" +
            "\t* \n" +
            "FROM\n" +
            "\tUSER u \n" +
            "WHERE\n" +
            "\tu.user_id BETWEEN 1 \n" +
            "\tAND 2")
    UserInfoDO getUserInfoByUserName(String username);

    List<User> selectList(@Param("ew") Wrapper<User> queryWrapper);


    @Select("select u.* from user u")
    List<User> selectTestList(IPage<User> page, Long id, @Param("name") String username);

    @Select("WITH t AS ( SELECT * FROM user WHERE user.user_name = 'test' ) SELECT t.* FROM t")
    void testWith();
}
